reproduce figures in paper

This notebook is meant for release to the general public, to reproduce the figures from our paper "Multiple mechanisms mediate the suppression of motion vision during escape maneuvers in flying Drosophila" https://doi.org/10.1101/2022.02.03.478949

Setup imports

These imports are necessary to run the notebook. The production environment is listed in "working_environment.txt".

The custom pathdefs package is a convenience for the author to simplify running on different machines. It exports two variables SOURCEPATH and DATAPATH , which may just as well be declared as regular variables.

The paths where the respective files are to be found will be different for other users as well, of course. Adapt to your folder structure.

Figure 1

Fig 1D

Fig 1E

ephys

wingDiff

visual angle of looming

Figure 2

loading data for Fig 2A&B

# TANGENT: HOW MANY TRIALS IN EACH STIMULUS saSacc.print_N_stims_per_fly() saStrg.print_N_stims_per_fly()

Fig 2A

L-R WBA of saccades and non-saccade trials

Fig 2B

Run section before figure 2A first to load all the data

loading data for Fig 2C&D

loads data and calculates amplitudes of membrane polarizations and L-R WSA for spontaneous saccades tp the left for setting line colors

Fig 2C

Plot L-R WBA of spontaneous saccades to the left, meaning R>L and L-R<0

Fig 2D

membrane potential corresponding to traces in Fig 2C

Fig 2E

Fig 2F

Fig 2G

Plotting membrane potential during spontaneous and escape saccades side-by-side for the hyperpolarizing group

Figure 3

load data for panels A&B

Fig 3A

Fig 3B

Fig 3C

The left part of this panel is a purely artistic schematic drawing. The right part is data-derived, though.

Load all flies flying

saFly = copy.deepcopy(anlyz) # saFly = sum(anlyz)### load all flies resting data
saRest = anlyz[:] # saRest = sum(anlyz)

calculate criterion

Fig 3D

Load datasets although we did that before in section 5.1, but it shoudln't be necessary to run that first.

Fig 3E

Load datasets although we did that before in section 5.1, but it shoudln't be necessary to run that first.

loading data for Fig 3F&G

Fig 3F

Plot spontaneous saccades L-R WSA for subsets in one plot

Fig 3G

Figure 4

Fig 4A

# LOAD BOTH anlyz = [] for root,fly in saccLeft_HyPol: a = lwb.Looming_with_background_Analyzer.retrieveFromNeomatfile(os.path.join(DATAPATH, root, f'{fly}looming_wb__flying.neomat')) helperLibrary.resampleAnalyzer(a) a.average_flywise() anlyz.append(a) saFly_Lhyp = sum(anlyz) saFly_Lhyp.average_flywise() anlyz = [] for root,fly in saccLeft_HyPol: a = lwb.Looming_with_background_Analyzer.retrieveFromNeomatfile(os.path.join(DATAPATH, root, f'{fly}looming_wb__resting.neomat')) helperLibrary.resampleAnalyzer(a) a.average_flywise() anlyz.append(a) saRest_Lhyp = sum(anlyz) saRest_Lhyp.average_flywise()

Fig4B

# LOAD BOTH flying and resting trial data anlyz = [] for root,fly in saccLeft_NoPol: a = lwb.Looming_with_background_Analyzer.retrieveFromNeomatfile(os.path.join(DATAPATH, root, f'{fly}looming_wb__flying.neomat')) helperLibrary.resampleAnalyzer(a) a.average_flywise() anlyz.append(a) saFly_Lnop = sum(anlyz) saFly_Lnop.average_flywise() anlyz = [] for root,fly in saccLeft_NoPol: a = lwb.Looming_with_background_Analyzer.retrieveFromNeomatfile(os.path.join(DATAPATH, root, f'{fly}looming_wb__resting.neomat')) helperLibrary.resampleAnalyzer(a) a.average_flywise() anlyz.append(a) saRest_Lnop = sum(anlyz) saRest_Lnop.average_flywise() del anlyz

Fig 4C

Fig 4D

Fig 4E

Uses the same data and same code as Fig 4C, only difference is the stimID

Fig 4F

Figure S1

Take the same fly as in the example raw data (Fig 1E), show a piece of Kinefly recording, then demonstrate the fitting procedure, then go to make a plot of CWT with 2-3 example scales, then highlight the ridges in them

load data and set trial number to plot

Fig S1A

Plot raw L-R WSA trace and the derived PWC-filtered version of the signal.

Fig S1B

Fig S1C

Fig S1D

Needs additional function declarations to redo the saccade detection as it happens in the analysis algorithm. Disentagle overlapping point markers later in Inkscape.

Figure S2

load data

Fig S2B

Fig S2C

This is essentially the same plot as in Fig S2B, only replacing the L-R WBA with ephys

Fig S2D